package com.umeox.watch.moto.dataservice.db.dao;


import android.database.Cursor;

import androidx.annotation.NonNull;
import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.OnConflictStrategy;
import androidx.room.Query;

import com.umeox.watch.moto.dataservice.db.model.LocationPeriod;

import java.util.List;

@Dao
public interface LocationPeriodDao {

    @Query("SELECT * FROM location_period WHERE :currentTime >= startTime AND :currentTime <= endTime")
    List<LocationPeriod> query(String currentTime);

    @Query("SELECT locPriority FROM location_period WHERE id = :id LIMIT 1")
    int queryLocPriorityById(long id);

    @Query("SELECT * FROM location_period")
    List<LocationPeriod> queryAll();

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    long save(@NonNull LocationPeriod locationPeriod);

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    void save(List<LocationPeriod> locationPeriods);

    @Delete
    int delete(LocationPeriod locationPeriod);

    @Delete
    void delete(List<LocationPeriod> locationPeriods);

    @Query("DELETE FROM location_period")
    int deleteAll();

    @Query("SELECT * FROM location_record")
    Cursor query();
}
